// // ******************************************************************
// //       /\ /|       @file       TranslationRecordService.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2025-02-20 20:02
// //    *(__\_\        @Copyright  Copyright (c) , 2025-01-04 17:01 Await
// // ******************************************************************

using System.ComponentModel;
using AutomaticSubtitles.Contracts.Dto;
using AutomaticSubtitles.Contracts.Vo;
using AutomaticSubtitles.Service.Application.TranslationRecord.Commands;
using AutomaticSubtitles.Service.Application.TranslationRecord.Queries;

namespace AutomaticSubtitles.Service.Services;

public class TranslationRecordService : BaseService<TestService>
{
    /// <summary>
    /// 获取翻译记录列表
    /// </summary>
    [EndpointSummary("获取翻译记录列表")]
    [Tags("翻译记录")]
    [EndpointDescription("获取翻译记录列表，支持多条件筛选和排序")]
    [Authorize]
    public async Task<ResponseModel<PaginatedResponseDto<TranslationRecordDto>>> PostTranslationRecordListAsync(
        [FromBody] TranslationRecordVo vo)
    {
        var query = new GetTranslationRecordListQuery(vo);
        await PublishAsync(query);
        return query.Result.CreateResult();
    }

    /// <summary>
    /// 删除翻译记录
    /// </summary>
    [EndpointSummary("删除翻译记录")]
    [Tags("翻译记录")]
    [EndpointDescription("删除翻译记录，可选是否同时删除源文件")]
    [Authorize]
    public async Task<ResponseModel<int>> DeleteTranslationRecordAsync(
        [FromBody] List<string> ids,
        [Description("是否删除源文件")] bool deleteSourceFile = false)
    {
        var command = new DeleteTranslationRecordCommand(ids, deleteSourceFile);
        await PublishAsync(command);
        return command.Result.CreateResult();
    }
}